//#include "libssh2_config.h"
#include <libssh2.h>
 
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <queue>
 

class ssh2client
{
	public:
		ssh2client(std::string const& ip);
	
		std::string command(std::string const& command);
	private:
    		LIBSSH2_SESSION *session;
    		LIBSSH2_CHANNEL *channel;
		    unsigned long hostaddr;
		    int sock;
		    struct sockaddr_in sin;
		    const char *fingerprint;
		    int rc;
		    int exitcode;
		    int bytecount = 0;
		    char *exitsignal=(char *)"none";
};





class sshQueue
{
public:
	sshQueue();
	struct Job
	{
		std::string ip;
		std::string command;
	};
	void add(std::string const& ip, std::string const& command)
	{
		Job job;
		job.ip = ip;
		job.command = command;
		m_jobs.push(job);
	}
	Job get()
	{
		while(m_jobs.empty())
			sleep(0);
		Job job = m_jobs.front();
		m_jobs.pop();
		return job;
	}

	std::queue<Job> m_jobs;
private:
	 pthread_t m_sshProcess;
}; 

/*
void* sshQueueThread(void *ptr)
{
        sshQueue* base = (sshQueue*)ptr;

        return NULL;
}
*/
